package icasue.net.socket.share;


import icasue.net.socket.thread.Channel;
import icasue.net.socket.thread.SocketProxy;
import icasue.net.socket.wareable.IdWorker;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author: Qiao Hang
 * @CreateDate: 2021/3/18 下午5:13
 * @UpdateDate:
 * @Description:
 */
public class MindManger {
    //IdWorker 用于生产客户端交互过程中业务组件的标识，要求具备业务唯一性
    //例如SocketProxy -> identity, Channel -> identity.
    public static IdWorker idWorker = null;
    //SocketServer和客户端通信的tcp端口，默认4477
    public static Integer tcpPort = 4477;
    //SocketServer实例间通信的tcp端口，默认4478
    public static Integer serverTcpPort = 4478;


    //游离态的Socket : socketId -> SocketRunner.
    public static volatile Map<Object, SocketProxy> freeSocket = new ConcurrentHashMap<>();
    //使用中的channels : channelId -> channelRunnder.
    public static volatile Map<Object, Channel> channels = new ConcurrentHashMap<>();

    

    //待清理的Socket线程(因为使用线程池的缘故，暂时不用自己清理该线程) : socketId -> socketThread.
    private static volatile Map<Long, Thread> clearSocketThread = new ConcurrentHashMap<>();
    //待清理的channels(因为使用线程池的缘故，暂时不用自己清理该线程) : channelId -> channelThread.
    private static volatile Map<String, Thread> clearChannelThread = new ConcurrentHashMap<>();
}
